//
//  LeftTitle_TextFieldView.m
//  Doctor
//
//  Created by 阳光 on 16/9/11.
//  Copyright © 2016年 阳光. All rights reserved.
//

#import "LeftTitle_TextFieldView.h"

@implementation LeftTitle_TextFieldView

-(instancetype)initWithTitle:(NSString *)title placeholder:(NSString *)placeholder
{
    if (self=[super init]) {
        
        self.leftTitle=title;
        _placeholder = placeholder;//.
        
        _leftTitleLabel=[UILabel new];
        [self addSubview:_leftTitleLabel];
        _leftTitleLabel.font=Font_Number(16);
        _leftTitleLabel.text=_leftTitle;
        
        _textField=[UITextField new];
        [self addSubview:_textField];
        _textField.font=Font_Number(14);
        _textField.placeholder=_placeholder;
        
        
//        self.leftTitle=title;
        self.leftTitleLabel.textColor=Color666666;
        self.textField.placeholder=placeholder;
        self.textField.hidden=NO;
        self.textField.textColor=ColorBDBDBD;
        self.backgroundColor=WhiteColor;
        
    
        BOOL isCN = [[LanguageConvert alloc] hasShownIsCnOrNot];//...
        if (isCN == YES) {
            
            self.leftTitleLabel.frame = CGRectMake(kmargin, kmargin/2, 65, 30);
            self.textField.frame = CGRectMake(CGRectGetMaxX(self.leftTitleLabel.frame)+10, 5, APPW-115, 30);
            
        } else if (isCN == NO) {//.EN;
            
            self.leftTitleLabel.frame = CGRectMake(kmargin, kmargin/2, 85, 30);
            self.textField.frame = CGRectMake(CGRectGetMaxX(self.leftTitleLabel.frame)+10, 5, APPW-135, 30);
        }
        
        
    };

    return self;
}



// 预防
- (instancetype)init {
    if (self = [super init]) {
        NSAssert1(NO, @"%s  必须使用initWithTitle:方法初始化", __FUNCTION__);
    }
    return self;
}

//- (UILabel *)leftTitleLabel
//{
//    if (!_leftTitleLabel) {
//        _leftTitleLabel=[UILabel new];
//        [self addSubview:_leftTitleLabel];
//        [_leftTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.mas_equalTo(kmargin);
//            make.top.mas_equalTo(kmargin/2);
//            make.bottom.mas_equalTo(-kmargin/2);
//            make.width.mas_equalTo(65);
//        }];
//        _leftTitleLabel.font=Font_Number(16);
//        _leftTitleLabel.text=_leftTitle;
//    }
//    return _leftTitleLabel;
//}
//
//
//- (UITextField *)textField
//{
//    if (!_textField) {
//        _textField=[UITextField new];
//        [self addSubview:_textField];
//        [_textField mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.mas_equalTo(self.leftTitleLabel.mas_right).offset(kmargin);
//            make.right.mas_equalTo(-kmargin);
//            make.centerY.mas_equalTo(self.leftTitleLabel.mas_centerY);
//            make.top.mas_equalTo(kmargin/2);
//        }];
//        _textField.font=Font_Number(14);
//        _textField.placeholder=_placeholder;
//    }
//    return _textField;
//}

@end


